package roborally.supporting;

import be.kuleuven.cs.som.annotate.Basic;
import be.kuleuven.cs.som.annotate.Immutable;
import be.kuleuven.cs.som.annotate.Raw;
import be.kuleuven.cs.som.annotate.Value;

/**
 * This enum represents the possible directions for turning. It is used for a 2 dimensional board 
 * with Manhattan movement.
 * 
 * @inv The direction of clockwise must be 1.
 * 		| Direction.CLOCKWISE.getDirection() == 1
 * @inv The direction of counterclockwise must be -1.
 * 		| Direction.COUNTERCLOCKWISE.getDirection() == -1
 * 
 * @author Molderez Tom, 2de bach Ingenieurswetenschappen Computerwetenschappen-Elektrotechniek and Reniers Jorn, 2de bach Ingenieurswetenschappen Werktuigkunde-Computerwetenschappen
 * @version 1.0
 *
 */
@Value
public enum Direction {
	CLOCKWISE(1),COUNTERCLOCKWISE(-1);
	
	/**
	 * Creates the direction objects.
	 * 
	 * @param direction The direction to be set.
	 * @post
	 * 		| (new this).getDirection() = direction
	 */
	private Direction(int direction) {
		this.direction = direction;
	}
	
	/**
	 * Returns the direction of this direction enum.
	 */
	@Basic @Raw @Immutable
	public int getDirection()  {
		return this.direction;
	}
	
	/**
	 * The direction of this direction enum.
	 */
	private final int direction;
	
	/**
	 * Returns a textual representation of this direction enum.
	 * 
	 * @return A textual representation of this direction enum.
	 * 		| if this.getDirection() == 1
	 * 		|	then result == "Direction: clockwise(" + this.getDirection() + ")"
	 * 		| if this.getDirection() == -1
	 * 		|	then result == "Direction: counterclockwise(" + this.getDirection() + ")"
	 * 		| else
	 * 		|	result == ""
	 */
	@Override
	public String toString() {
		if(this.getDirection() == 1)
			return this.getClass().getSimpleName() +  ": clockwise(" + this.getDirection() + ")";
		if(this.getDirection() == -1)
			return this.getClass().getSimpleName() + ": counterclockwise(" + this.getDirection() + ")";
		return "";
	}
}
